<?php

namespace api\controller;

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\UserFavoritesService;
use think\Exception;
use think\Request;
/**
 *  用户收藏
 */
class UserFavoritesController extends VerifyController
{

    private $service;

    public function __construct()
    {
        parent::__construct();
        $this->service = UserFavoritesService::getInstance();
    }

    /**
     * 获取用户收藏
     *
     * @param \think\Request $request
     *
     * @return \think\Response
     */
    public function getUserFavorites(Request $request)
    {
        $userId   = $request->getUserId();
		$param = $request->param()['param'];
        $result = $this->service->getUserFavorites( $param,$userId);

        return json(success_response('ok', $result));

    }

    /**
     * 新增用户收藏
     *
     * @param \think\Request $request
     * @return \think\Response
     */
    public function createUserFavorites(Request $request)
    {
        $param    = $request->param();
        $userId   = $request->getUserId();
        $result = $this->service->createUserFavorites($param['param'], $userId);

        return json(success_response('ok', $result));

    }



    /**
     * 删除收藏
     * @param \think\Request $request
     *
     * @return \think\Response
     */
    public function deleteUserFavorites(Request $request)
    {
        $param = $request->param()['param'];
        $userId   = $request->getUserId();
        $result = $this->service->deleteUserFavorites($param, $userId);
        return json(success_response('ok', $result));
    }

}
